package com.sfac.springBoot.config.shiro;

import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * personal demo
 **/

@Configuration
public class ShiroConfiguration {

    @Autowired
    private MyRealm myRealm;

    @Bean
     public DefaultSecurityManager defaultSecurityManager(){
         DefaultSecurityManager manager = new DefaultSecurityManager();
         manager.setRealm(myRealm);
         return manager;
     }

     @Bean
     public ShiroFilterFactoryBean shiroFilterFactoryBean(){

         ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();

         //设置 SecurityManager
         factoryBean.setSecurityManager(defaultSecurityManager());

         //设置登录地址和登陆成功地址
         factoryBean.setLoginUrl("/login");
         factoryBean.setSuccessUrl("/test/thymeleafTest");

         //设置过滤器




         return null;
     }
}
